#include <QTextStream>
#include <QWidget>

#include "generalsettings.h"
#include "ui_generalsettings.h"

GeneralSettings::GeneralSettings(QObject *parent) :
    Core::IOptionsPage(parent),
    ui(0)
{
}

GeneralSettings::~GeneralSettings()
{
}

QString GeneralSettings::id() const
{
    return "generalsettings";
}

QString GeneralSettings::displayName() const
{
    return tr("General");
}

QString GeneralSettings::category() const
{
    return "general";
}

QString GeneralSettings::displayCategory() const
{
    return tr("General");
}

QIcon GeneralSettings::categoryIcon() const
{
    return QIcon(":/core/images/settings-general.png");
}

bool GeneralSettings::matches(const QString &searchKeyWord) const
{
    return m_keywords.contains(searchKeyWord, Qt::CaseInsensitive);
}

QWidget * GeneralSettings::createPage(QWidget *parent)
{
    QWidget *w = new QWidget(parent);
    ui = new Ui::GeneralSettings();

    ui->setupUi(w);

    if (m_keywords.isEmpty()) {
        QTextStream(&m_keywords) << ui->groupBoxUi->title() << ' '
                << ui->labelLanguage->text();
        m_keywords.remove(QLatin1Char('&'));
    }
    return w;
}

void GeneralSettings::apply()
{

}

void GeneralSettings::finish()
{
    delete ui;
}
